import axios from 'axios'

const instance = axios.create({
    baseURL: "https://www.ahsj.link/nebula-api",
    timeout: 5000
})
let urls = ['/api/star']
// 请求拦截器
instance.interceptors.request.use(config => {
    urls.forEach(e => {
        if (e == config.url) {
            config.headers['Content-Type'] = "application/x-www-form-urlencoded"
        }
    })
    const token = sessionStorage.getItem('token');

    if (token) {
        config.headers['x-auth-token'] = token
    }
    return config
})
// 响应拦截器
instance.interceptors.response.use(res => {
    return res.data
})
export default instance
